package com.study.mq;


import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class MqPub {
	public static void main(String[] args) throws IOException, TimeoutException {
		Connection connection = MqUtils.getConnection();

		Channel channel = connection.createChannel();
		//queueName不存在,自动构建queue.
		channel.queueDeclare("hello", true, false, false, null);
		channel.exchangeDeclare("a", "fanout");
		int count = 1;
		for (int i = 0; i < 20; i++) {
			channel.basicPublish("", "hello", MessageProperties.PERSISTENT_TEXT_PLAIN, ("hyj" + count++).getBytes());

		}

		channel.close();
		connection.close();
	}
}
